﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace HeavenvsDarkness
{

    public class MyCamera : GameEntity
    {
        float _nearDistance;

        public float NearDistance
        {
            get { return _nearDistance; }
            set { _nearDistance = value; }
        }
        float _farDistance;

        public float FarDistance
        {
            get { return _farDistance; }
            set { _farDistance = value; }
        }
        float _aspectRatio;

        public float AspectRatio
        {
            get { return _aspectRatio; }
            set { _aspectRatio = value; }
        }
        float _openField;

        public float OpenField
        {
            get { return _openField; }
            set { _openField = value; }
        }
        Matrix _view;

        public Matrix View
        {
            get { return _view; }
            set { _view = value; }
        }

        Vector3 _position;

        public Vector3 Position
        {
            get { return _position; }
            set { _position = value; }
        }
        Vector3 _target;

        public Vector3 Target
        {
            get { return _target; }
            set { _target = value; }
        }
        Vector3 _vectorUp;

        public Vector3 VectorUp
        {
            get { return _vectorUp; }
            set { _vectorUp = value; }
        }
        Matrix _projection;

        public Matrix Projection
        {
            get { return _projection; }
            set { _projection = value; }
        }
        public MyCamera()
        {

        }

        public MyCamera(
            Vector3 position,
            Vector3 target,
            Vector3 upVector,
            float openField,
            float aspect,
            float nearDistance,
            float farDistance)
        {
            Position = position;
            Target = target;
            VectorUp = upVector;


            OpenField = openField;
            AspectRatio = aspect;
            NearDistance = nearDistance;
            FarDistance = farDistance;

            InternalUpdate();
        }

        public void InternalUpdate()
        {
            View = Matrix.CreateLookAt(Position, Target, VectorUp);
            Projection = Matrix.CreatePerspectiveFieldOfView(OpenField, AspectRatio, NearDistance, FarDistance);
        }

        public override void Update(GameTime gameTime)
        {
            InternalUpdate();
        }
    }
}
